module(..., package.seeall)
require "common"
CHAR_WIDTH = 24
function rgb(r, g, b)
    return (r - r % 8) / 8 * 2048 + (g - g % 4) / 4 * 32 + (b - b % 8) / 8
end

function text(s, x, y, r, g, b)
    if r and g and b then
        disp.setcolor(rgb(r, g, b))
    end
    disp.puttext(common.utf8ToGb2312(s), x, y)
end

--居中显示文字
function putStringCenter(s, x, y, r, g, b)
    local str = common.utf8ToGb2312(s)
    text(s, x - str:len() * ((CHAR_WIDTH - CHAR_WIDTH % 2) / 2), y, r, g, b)
end

sys.taskInit(function()
    local cnt=0
   
    sys.waitUntil("LCD_INIT")
    log.info("LCD", "已进入")
    disp.setfontheight(32)
    while true do
        putStringCenter(cnt, 70, 60, 220, 220, 220)
        disp.update()  
        cnt=cnt+1 
        sys.wait(100)
        disp.clear()
    end
    
   


end)
